package com.ficus.road.maintain.core.model.coverage;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.ficus.road.maintain.core.model.RoadCoverDetail;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @author xiawen yang
 * @date 2022/3/15 下午2:31
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class RoadCoverageYT {

    @Id
    private String id;

    private String roadId;

    private String roadSecNum;

    private String unitId;

    private String cycleNum;

    private String day;

    private Date lastModificationTime;

    private double cycleCoverage;

    private Double workLength;

    private Double workLengthAll;

    private Set<Integer> coverageLocationIndex;

    private Integer indexLength;

    private RoadCoverDetail.RoadCoverageStatusEnum status;

    private RoadDirectionEnum direction;

    public enum RoadDirectionEnum {
        //上行
        UP("UP"),
        //下行
        DOWN("DOWN"),
        //无方向,单行
        NONE("NONE");

        private final String value;

        RoadDirectionEnum(String value) {
            this.value = value;
        }

        @JsonValue
        public String getValue() {
            return value;
        }

        @Override
        public String toString() {
            return String.valueOf(value);
        }

        @JsonCreator
        public static RoadDirectionEnum fromValue(String value) {
            for (RoadDirectionEnum b : RoadDirectionEnum.values()) {
                if (b.value.equals(value)) {
                    return b;
                }
            }
            throw new IllegalArgumentException("Unexpected value '" + value + "'");
        }
    }
}
